<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<table width="80%" border="0" cellspacing="0" cellpadding="2" align="center">
	<tr>
		<td colspan="6">
				<img src="<%=request.getContextPath() %>/image/board1.jpg" width="170px" height="100px">
		</td>
	</tr>
	<tr>
		<td align="right" colspan="6">
			<input type="button" value="글쓰기" onclick="location.href='boardWrite.do'"  style="width: 120px;height: 22px">
		</td>
	</tr>
	<tr bgcolor="#d3d3d3">
		<th width="50" style=" border-bottom:1px solid #8C8C8C;">번호</th>
		<th width="50"  style=" border-bottom:1px solid #8C8C8C;">등급</th>
		<th  style=" border-bottom:1px solid #8C8C8C;">제목</th>
		<th width="90"  style=" border-bottom:1px solid #8C8C8C;">글쓴이</th>
		<th width="150"  style=" border-bottom:1px solid #8C8C8C;">날짜</th>
		<th width="50"  style=" border-bottom:1px solid #8C8C8C;">조회수</th>
	</tr>
	<c:forEach var="article" items="${nlist}">
		<tr>
			<th style="background-color: #FFFF8F; border-bottom:1px solid #8C8C8C;">${article.b_num }</th>
			<th style="background-color: #FFFF8F;border-bottom:1px solid #8C8C8C;">
				<c:if test="${article.b_open == 0}">공개</c:if>
				<c:if test="${article.b_open == 1}">비밀</c:if>
				<c:if test="${article.b_open == 2}">공지</c:if>
			</th>
			<td style="background-color: #FFFF8F;border-bottom:1px solid #8C8C8C;"><a href="detailBoard.do?b_num=${article.b_num }"><font style="font-weight: bold;color:#5F00FF">${article.b_title } <c:if test="${article.pos > 0}">[${article.pos }]</c:if></font></a></td>
			<th style="background-color: #FFFF8F;border-bottom:1px solid #8C8C8C;">${article.m_id }</th>
			<th style="background-color: #FFFF8F;border-bottom:1px solid #8C8C8C;">${article.b_date }</th>
			<th style="background-color: #FFFF8F;border-bottom:1px solid #8C8C8C;">${article.b_hits }</th>
		</tr>
	</c:forEach>

	<c:if test="${count==0}">
		<tr><td colspan="5" align="center"  style=" border-bottom:1px solid #8C8C8C;">등록된 게시물이 없습니다.</td> </tr>
	</c:if>
	<c:forEach var="article" items="${list}">
		<tr>
			<td align="center"  style=" border-bottom:1px solid #8C8C8C;">${article.b_num }</td>
			<td align="center"  style=" border-bottom:1px solid #8C8C8C;">
				<c:if test="${article.b_open == 0}">공개</c:if>
				<c:if test="${article.b_open == 1}"><font style="color: #8C8C8C">비밀</font></c:if>
				<c:if test="${article.b_open == 2}"><font style="font-weight: bold">공지</font></c:if>
			</td>
			<td  style=" border-bottom:1px solid #8C8C8C;">
			<c:choose>
				<c:when test="${article.b_open == 0 }"> <!-- 공개글일때 -->
					<a href="detailBoard.do?b_num=${article.b_num }">${article.b_title } <c:if test="${article.pos > 0}">[${article.pos }]</c:if></a>
				</c:when>	
				<c:when test="${article.b_open == 1 }"><!-- 비공개글일때 -->
					<c:if test="${article.m_id  != userId && userLevel <= 3}">
						<font style="color: #8C8C8C">비밀글입니다.<c:if test="${article.pos > 0}">[${article.pos }]</c:if></font>
					</c:if>
					<c:if test="${article.m_id  == userId || userLevel > 3}"><!-- 비공개글인데 아이디가 같을때 --> 
						<a href="detailBoard.do?b_num=${article.b_num }">${article.b_title } <c:if test="${article.pos > 0}">[${article.pos }]</c:if></a>
					</c:if>
				</c:when>
				<c:otherwise>
					<a href="detailBoard.do?b_num=${article.b_num }">${article.b_title } <c:if test="${article.pos > 0}">[${article.pos }]</c:if></a>
				</c:otherwise>
			</c:choose>
			</td>
			<td align="center"  style=" border-bottom:1px solid #8C8C8C;">${article.m_id }</td>
			<td align="center"  style=" border-bottom:1px solid #8C8C8C;">${article.b_date}</td>
			<td align="center"  style=" border-bottom:1px solid #8C8C8C;">${article.b_hits}</td>

		</tr>
	</c:forEach>
	<tr>
		<td align="center" colspan="6">${pagingHtml}</td>
	</tr>
	<form action="boardList.do" name="search" method="get" onsubmit="return searchCheck()">
	<table width="200" align="center" border="0" cellspacing="0" cellpadding="2">
		<tr>
			<td align="center">	
				<select name="keyField">
					<option value="b_title">제목</option>
					<option value="m_id">작성자</option>
						<option value="b_content">내용</option>
					<option value="all">전체</option>
				</select>
			</td>
			<td>
				<input type="text" size="16" name="keyWord">
			</td>
			<td>
				<input type="submit" value="찾기">
			</td>
		</tr>
	</table>
</form>
</table>
